﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeRepositoryConsole
{
    class Program
    {
        const int Size = 100000;
        static void Main(string[] args)
        {

            string strT = "fff";
            Foo();
            Console.WriteLine(strT
                );

            Console.WriteLine("Hello osChina!");
            var DapperTestDriver = new CodeRepositoryConsole.ORM.Dapper.DapperTestDriver();
            DapperTestDriver.Test();

            byte[] bytes = new byte[] { 1, 15, 127, 255 };
            Console.WriteLine(CodeRepositoryConsole.FCL.ByteArrayToHexString.ByteArrayToHexViaLookup(bytes));
            Console.WriteLine(CodeRepositoryConsole.FCL.ByteArrayToHexString.ByteArrayToHexStringViaStringConcatArraryConvertAll(bytes));

            //System.Diagnostics.Debug.Assert(false);

            object[] array = new object[Size];
            long initialMemory = GC.GetTotalMemory(true);
            for (int i = 0; i < Size; i++)
            {
                array[i] = new string[0];
            }
            long finalMemory = GC.GetTotalMemory(true);
            GC.KeepAlive(array);

            long total = finalMemory - initialMemory;

            Console.WriteLine("Size of each element: {0:0.000} bytes",
                              ((double)total) / Size);

            Test1();
            Test2();

            Console.ReadKey();
        }

        [System.Diagnostics.Conditional("DEBUG")]
        static void Foo()
        {
            Console.WriteLine("conditional");           
        }

        public static void Test1()
        {
            Action a = () => Console.WriteLine("A1");
            Action b = () => Console.WriteLine("B1");

            Action c = a + b;
            c();
        }

        public static void Test2()
        {
            Action a = () => Console.WriteLine("A2");
            Action b = () => Console.WriteLine("B2");

            Action c = (Action)MulticastDelegate.Combine(a, b);
            c();
        }

    }

}
